package com.travel.group.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.travel.group.dao.CommentMapper;
import com.travel.group.entity.Comment;
import com.travel.group.service.CommentService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements CommentService {

    @Override
    public List<Comment> getByCommentIds(List<Integer> ids) {
        return baseMapper.selectBatchIds(ids);
    }

    @Override
    public List<Comment> getAllCommentInfoPlus(Integer page, Integer limit, String number) {
        PageHelper.startPage(page, limit);
        List<Comment> comments = baseMapper.selectList(new QueryWrapper<Comment>().like("user_id", number));
        return comments;
    }

    @Override
    public List<Comment> getAllCommentInfo(Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        List<Comment> comments = baseMapper.selectList(null);
        return comments;
    }

    @Override
    public Integer countData() {
        List<Comment> comments = baseMapper.selectList(null);
        return comments.size();
    }

}
